<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateChannelsAndChannelProviders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('channels')) {
            Schema::create('channels', function (Blueprint $table) {
                $table->increments('id');
                $table->string('code', 16)->unique();
                $table->integer('no');
                $table->integer('channel_provider_id');
                $table->string('channel_provider_name', 64);
                $table->tinyInteger('cooperation');
                $table->tinyInteger('target');
                $table->date('start_date');
                $table->date('end_date');
                $table->tinyInteger('contract_type');
                $table->integer('contract_amount');
                $table->integer('real_amount');
                $table->text('expections');
                $table->tinyInteger('check_status');
                $table->tinyInteger('open_status');
                $table->timestamps();
            });
        }
        if(!Schema::hasTable('channel_providers')) {
            Schema::create('channel_providers', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name', 64);
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('channels');
        Schema::drop('channel_providers');
    }
}
